package com.xidian.zhiancloud.controller.chemicalsManagement.healthPart;

import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.HealthReport;
import com.xidian.zhiancloud.service.chemicalsManagement.healthManger.HealthReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 *
 * @Author: Egoist
 * @Date: 2020/11/10 17:31
 */

@RestController
@RequestMapping("/HealthReport")
public class HealthReportController {

    @Autowired
    private HealthReportService healthReportService;


    @PostMapping("/add")
    public ResultDTO add(HealthReport healthReport) {
        healthReportService.add(healthReport);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }

    @GetMapping("/getById")
    public ResultDTO getById(Long id) {

        return ResultDTO.successOf(healthReportService.getByIds(id), GeneralResponseEnums.SUCCESS);
    }

    @PostMapping("/deleteByIds")
    public ResultDTO deleteByIds(Long[] ids) {
        healthReportService.deleteByIds(ids);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }

    @PostMapping("/patchById")
    public ResultDTO patchById(HealthReport healthReport) {
        healthReportService.patchById(healthReport);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }

    @GetMapping("/getList")
    public ResultDTO getList(@RequestParam(value = "key", required = false) String key,
                             @RequestParam(value = "companyId", required = true) Long companyId,
                             @RequestParam(value = "current", required = true) int current,
                             @RequestParam(value = "size", required = true) int size){
        return ResultDTO.successOf(healthReportService.getList(key, companyId, current, size), GeneralResponseEnums.SUCCESS);
    }
}
